/*
HashRouter:有#号
BrowserRouter:没有#号
Route：设置路由与组件关联
Switch:只要匹配到一个地址不往下匹配，相当于for循环里面的break
Link:跳转页面，相当于vue里面的router-link
exact :完全匹配路由
Redirect:路由重定向
*/
import React,{lazy,Suspense} from 'react';
import {HashRouter as Router,Route,Switch,Redirect} from 'react-router-dom';
import {AuthRoute} from './routes/private';
const MainPage = lazy(() => import("./pages/home/main"));
const GoodsClassify = lazy(() => import("./pages/home/goods/classify"));
const GoodsSearch = lazy(() => import("./pages/home/goods/search"));
const GoodsDetails = lazy(() => import("./pages/home/goods/details"));
const LoginIndex = lazy(() => import("./pages/home/login"));
const RegIndex = lazy(() => import("./pages/home/reg"));
const BalanceIndex = lazy(() => import("./pages/home/balance"));
const AddressIndex = lazy(() => import("./pages/home/address"));
const AddressAdd = lazy(() => import("./pages/home/address/add"));
const AddressModify = lazy(() => import("./pages/home/address/modify"));
const balanceEnd = lazy(() => import("./pages/home/balance/end"));
const ProfileIndex = lazy(() => import("./pages/user/profile"));
const MyOrderIndex = lazy(() => import("./pages/user/myorder"));

class RouterComponent extends React.Component{
    render(){
        return (
            <React.Fragment>
                <Router>
                    <React.Fragment>
                        <Suspense fallback={<React.Fragment/>}>
                            <Switch>
                                <Route path={window.base.config.path+"home"} component={MainPage}></Route>
                                <Route path={window.base.config.path+"goods/classify"} component={GoodsClassify}></Route>
                                <Route path={window.base.config.path+"goods/search"} component={GoodsSearch}></Route>
                                <Route path={window.base.config.path+"goods/details"} component={GoodsDetails}></Route>
                                <Route path={window.base.config.path+"login/index"} component={LoginIndex}></Route>
                                <Route path={window.base.config.path+"reg/index"} component={RegIndex}></Route>
                                <AuthRoute path={window.base.config.path+"balance/index"} component={BalanceIndex}></AuthRoute>
                                <AuthRoute path={window.base.config.path+"address/index"} component={AddressIndex}></AuthRoute>
                                <AuthRoute path={window.base.config.path+"address/add"} component={AddressAdd}></AuthRoute>
                                <AuthRoute path={window.base.config.path+"address/modify"} component={AddressModify}></AuthRoute>
                                <AuthRoute path={window.base.config.path+"balance/end"} component={balanceEnd}></AuthRoute>                                {/*<AuthRoute path={window.base.config.path+"goods"} component={GoodsPage}></AuthRoute>*/}
                                <AuthRoute path={window.base.config.path+"profile/index"} component={ProfileIndex}></AuthRoute>
                                <AuthRoute path={window.base.config.path+"myorder"} component={MyOrderIndex}></AuthRoute>
                                <Redirect to={window.base.config.path+"home/index"}></Redirect>
                            </Switch>
                        </Suspense>
                    </React.Fragment>
                </Router>
            </React.Fragment>
        )
    }
}

export default RouterComponent;
